<template>
    <div class="bg-white rounded-8px mb-20px">
        <div class="p-30px flex justify-between text-24px font-600">
            游戏竞赛
        </div>
    </div>
    <div class="bg-white rounded-8px mb-20px">
        <div class="p-30px text-24px">
           
        </div>
        
    </div>
    
</template>
<script setup>
    import { Edit,Search } from '@element-plus/icons-vue'
    import { ref,onMounted,computed,watch, nextTick } from 'vue'
    import { useRoute,useRouter } from 'vue-router'
    import { useUserStore } from '../../stores/user'
    import { systemApi,userApi,httpApi } from '../../api/api'
    import { configStore } from '../../stores/config'
    import { Minus, Plus } from '@element-plus/icons-vue';
    import DOMPurify from 'dompurify';
    import { ElMessage } from 'element-plus';

    const config = configStore()
    const userStore = useUserStore()
    const totalPages=ref(0)
    const total = ref(0)
    const complete=ref(0)
    const currentPage = ref(1)
    const communityList = ref([])
    const keyword = ref('')
    const router = useRouter()
    const dialogVisible = ref(false)
    const configHeaders = ref({})
    const uploadUrl = ref('')
    const imageUrl = ref('')
    const postData = ref({})
    const type = ref(1)


    
    const init = async ()=>{
        let configData = config.getConfig()
        let token = userStore.getToken()
        uploadUrl.value = configData.upload.uploadurl
        
        configHeaders.value = {
            'token':token
        }
        let params = {page:currentPage.value}
        if(keyword.value){
            params.keyword = keyword.value
        }
        let res = await httpApi.getCommunityList(params)
        if(res.code){
            communityList.value = res.data.list
            total.value = res.data.total
           
        }
    }
    const goClassmateDetail = (id)=>{
        console.log(id)
        router.push({name:'ClassmateDetail',query:{com_id:id}})
    }

    const handleCurrentChange = (value)=>{
        currentPage.value = value
        init()
    }

    const handleSearch = ()=>{
        init()
    }

    const handleAvatarSuccess = (response, uploadFile) => {
        //console.log(uploadFile.response.data.url);
        imageUrl.value = uploadFile.response.data.fullurl;
        postData.value.com_img = uploadFile.response.data.url
    }

    const submit = async ()=>{
        postData.value.com_type = type.value
        let res = await httpApi.addContent(postData.value)
        if(res.code){
            ElMessage.success(res.msg)
            dialogVisible.value = false
            init()
        }
    }

    const goReply = ()=>{
        dialogVisible.value = true
    }


    onMounted(()=>{
        init()
    })

</script>
<style scoped>
    .listItem:hover{
        background-color:rgba(254, 226, 226, 1);
        cursor: pointer;
    }
</style>